/*
 * Copyright (C) 2011 Fabio Hufschmid at bfh.ch
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package ch.bfh.aeneas.core.io.gesture;

import android.app.ListActivity;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import ch.bfh.aeneas.R;
import ch.bfh.aeneas.exchange.intent.AeneasIntent;


/**
 * Is responsible to offer the user the different modes to define a gesture 
 * @author Fabio Hufschmid at bfh.ch
 */
public class GestureBuilder extends ListActivity {

    private Resources res;
    private String[] mlistItems;
    
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);     
        res=getResources();
        mlistItems=res.getStringArray(R.array.modes_array);
        setContentView(R.layout.gesturebuilder_act_list);
        setListAdapter(new ArrayAdapter(this, 
              android.R.layout.simple_list_item_1, mlistItems));
        setTitle(R.string.gesturebuilder_title);
    }
    
    /**This methode sends the choosen itemid to the next class
     * 
     * {@inheritDoc}
     */
    @Override
    protected void onListItemClick(ListView l, View v, int position, long id) {
        String item = Long.toString(getListAdapter().getItemId(position));
        Intent mIntent = new Intent(this,GestureBuilderContextMenu.class);	
        mIntent.putExtra("SelectedElement", item);
        this.startActivity(mIntent);
    }
    
        /**Sends a broadcast for e primitve TTS Output
     * 
     * @param inText the text which is to speak
     */
    public void speech(String inText)
    {
        Intent output = new Intent(AeneasIntent.ACTION_OUTPUT);
        output.putExtra("offAISpeech", inText);
        sendBroadcast(output);
    }
     
    /**Sends a broadcast for en intelligent TTS Output
     * 
     * @param inText the text which is to speak
     */
     public void speechAiOn(String inText)
    {
        Intent output = new Intent(AeneasIntent.ACTION_OUTPUT);
        output.putExtra("Speech", inText);
        super.sendBroadcast(output);
    }
}
